#!/bin/sh
#
# $FreeBSD: ports/net/freeradius2/files/radiusd.sh.in,v 1.7 2010/04/11 11:43:26 wxs Exp $
#
# PROVIDE: radiusdhcp
# REQUIRE: NETWORKING SERVERS
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable radiusdhcp:
#
# radiusdhcp_enable="YES"
#

. /etc/rc.subr

name=radiusdhcp
rcvar=`set_rcvar`
load_rc_config $name

command=/usr/local/sbin/radiusd
radiusdhcp_flags="-d /usr/local/etc/raddb.dhcp"

# In debug mode, radiusd doesn't create a pid file, so comment pidfile and
# let rc.subr use a process check on procname (which defaults to command).
pidfile=/var/run/radiusd/radiusdhcp.pid

extra_commands="reload debug"
debug_cmd="radiusd_debug"


# The radiusd_config parameter is now obsolete. Instead, derive the
# configuration directory name from radiusdhcp_flags if possible, otherwise
# default to /usr/local/etc/raddb
required_dirs=`echo ${radiusdhcp_flags} | sed -Ene 's:.*\-[^[:space:]d]*d[[:space:]]*([^[:space:]]+).*:\1:p'`
required_dirs=${required_dirs:-"/usr/local/etc/raddb.dhcp"}

required_files="${required_dirs}/radiusd.conf"

radiusdhcp_enable=${radiusdhcp_enable-"NO"}

command_args="&"

radiusdhcp_debug()
{
    radiusdhcp_flags="-X ${radiusdhcp_flags}"
    run_rc_command start
}


run_rc_command "$1"
